let context =null 
const initContext=(vue)=>{
	context = vue;
}

//重置密码
const resetPwdAsync = async(usercell,authCode)=>{
	let requrl=`${context.serverUrl}/Account/Reset`;
	let [error, result] = await uni.request({
		url:requrl,
		method:"POST",
		data:{
			UserId:usercell,
			AuthCode:authCode,
		}
	});
	if (!error && result.statusCode == 200) {
		return result.data;
	}
	return null;
}

//发送验证码
const phoneVerificationCodeAsync = async(userPhone)=>{
	debugger;
	let requrl=`${context.serverUrl}/Account/PhoneAuthCode`;
	let [error, result] = await uni.request({
		url:requrl,
		method:"POST",
		data:{
			PhoneId:userPhone,
		}
	});
	if (!error && result.statusCode == 200) {
		return result.data;
	}
	return null;
}
const checkPhone = (strphone) =>{
	let ret = /^1[0-9]{10,10}$/
	if(ret.test(strphone))
		return true;
	else
		return false;
}
const resetPwdService = {
	initContext,
	resetPwdAsync,
	phoneVerificationCodeAsync,
	checkPhone
}
export default resetPwdService